package com.roncoo.eshop.product.ha.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.roncoo.eshop.product.ha.model.ProductInfo;

/**
 * Copyright: Copyright (c) 2019 Hu-Cheng
 *
 * @ClassName: ProductController.java
 * @Description: 商品服务接口
 *
 * @version: v1.0.0
 * @author: hucheng
 * @date: Nov 13, 2019 1:19:20 PM
 *
 */
@Controller
public class ProductController {

	@RequestMapping("/getProductInfo")
	@ResponseBody
	public String getProductInfo(Long productId) {
		ProductInfo productInfo = new ProductInfo(productId, "iphone7手机", 5599.0, "a.jpg,b.jpg", "iphone7的规格",
				"iphone7的售后服务", "红色,白色,黑色", "5.5", 1L, "2017-01-01 12:01:00",1L,null,1L,null);
		return JSONObject.toJSONString(productInfo);
	}
	
	@RequestMapping("/getProductInfos")
	@ResponseBody
	public String getProductInfos(String productIds) {
		JSONArray products = new JSONArray();
		for (String productId : productIds.split(",")) {
			ProductInfo productInfo = new ProductInfo(Long.valueOf(productId), "iphone7手机", 5599.0, "a.jpg,b.jpg", "iphone7的规格",
					"iphone7的售后服务", "红色,白色,黑色", "5.5", 1L, "2017-01-01 12:01:00",1L,null,1L,null);
			products.add(productInfo);
		}
		return products.toJSONString();
	}
}
